import pandas as pd
import numpy as  np

Train = pd.read_csv("train.csv")
# -------------缺失值查找
age = Train["Age"]
age_is_null = pd.isnull(age)
# print(age_is_null)
age_null_true = age[age_is_null]
# print(age_null_true)
age_null_count = len(age_null_true)
# print(age_null_count)
# ----------------求均值------------

ok_age = Train["Age"][age_is_null == False]
# print(ok_age)
right_mean_age = sum(ok_age)/len(ok_age)
# print(right_mean_age)

right_mean_age = Train["Age"].mean()
# print(right_mean_age)
# ----------------舱位等级-------
passenger = Train.pivot_table(index="Embarked",values=["Fare","Survived"],aggfunc=np.sum)
# print(passenger)
# ----------------------丢弃数据
drop_na_columns = Train.dropna(axis=1)
new_drop = Train.dropna(axis=0,subset=["Age","Sex"])
print(drop_na_columns)